<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

  <script>
    /**
     * 1 ~ 100 随机数
     * 60  分为及格线
     * 大于 60分为成功  
     * 打印: 恭喜及格
     * 小于 60分为失败
     * 打印: 继续努力
    */
    function rand(a,b) {
      return Math.floor(Math.random() * (Math.abs(a - b) + 1)) + Math.min(a,b)
    }

    let p = new Promise( (resolve, reject) => {
      // 执行器内部封装操作
      let result = rand(1,100)
      if (result >= 60 ) {
        resolve(result)
      } else {
        reject(result)
      }
    })

    p.then(value => {
      console.log('恭喜及格:', value);
    }, reason => {
      console.log('继续努力:', reason);
    })

  </script>


</body>
</html>